package com.jeebey.mybatis.utils;

import java.util.UUID;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class StrCharUtil {
	public static int countSubStr(String str, String sub) {
		int iCount = 0, iSubLen = sub.length();
		for (int iLength = 0; (iLength = str.indexOf(sub)) > 0; iCount++) {
			str = str.substring(iLength + iSubLen);
		}
		return iCount;
	}

	public static int countSubStr2(String str, String sub) {
		Pattern p = Pattern.compile(sub, Pattern.CASE_INSENSITIVE);
		Matcher m = p.matcher(str);
		int iCount = 0;
		while (m.find()) {
			iCount++;
		}
		return iCount;
	}

	public static String uuid() {
		return UUID.randomUUID().toString().replace("-", "");
	}

	public static String shortuuid() {
		return UUIDCharUtil.uuid();
	}
}
